package com.thank.concurrency.samples.publish;

import java.util.List;

/**
 * 演示方法逃逸的例子
 */
public class EscapeAnalysis1 {

    // 1. Resource对象通过返回值逃逸
    public Resource newInstance() {
        Resource resource = new Resource();
        return resource;
    }

    // 2. Resource对象通过参数逃逸
    public void initResource(List<Resource> resources) {
        if (null != resources) {
            Resource resource = new Resource();
            resources.add(resource);
        }
    }
}

